package com.bafa.front;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.bafa.exceptions.ErrorException;
import com.bafa.front.presentationbeans.ResultsListBean;
import com.bafa.objects.player.Player;
import com.bafa.objects.season.Division;
import com.bafa.objects.Match;
import com.bafa.objects.Scorer;
import com.bafa.services.RetrieveServices;

public class DisplayLeagueServlet extends DaddyServlet{

	@Override
	public void doEvent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, ErrorException {
		Division division = new Division();
		
		division = RetrieveServices.getDivision(request.getParameter("SeasonId"),request.getParameter("Division"));
		String[] scorers = RetrieveServices.getDivisionTopScorers(division.getDivision(),division.getSeasonId()+"");
		ResultsListBean recentResults = new ResultsListBean(division.matchArray());
		request.setAttribute("RECENTRESULTS",recentResults);
		request.setAttribute("TOPSCORERS",scorers);
		HttpSession session = request.getSession();
		session.setAttribute("DIVISION",division);
		
		url = "division.jsp";
		
	}
	

}
